<?php
$GLOBALS['Md'] = "TimeClock";
$GLOBALS['Pd'] = "N";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
module($BSD['DB00']);
include($GLOBALS['PAD']."Modules/Exchange/main.obj.php");
	
	$QCall = "SELECT * FROM exchange_operations WHERE ref = {$_GET['ref']}";
	$Call = $GLOBALS['CONN']->db_array($QCall);
?>
<html>
<head><style type="text/css">
body{ background-color:#FFFFFF;
background-image:none; 
color:#000000}
td{{font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:9px}
#top {display:none;}
#bottom{ display:none;}
</style></head>
<body>
<script charset="utf-8" type="text/javascript">window.print();</script>
<div id="top" style="margin-top: -100px; bottom:150px; position:relative; background-color:#FFFFFF"></div>
<br>
<table width="500" height="340"  border="0" align="center">
  <tr>
    <td colspan="2" align="center"><div align="right">Original</div></td>
  </tr>
  <tr>
    <td height="80" align="center"><img src="<?php echo $GLOBALS['GFX'];?>mini_logo.gif" 

alt="<?php echo $GLOBALS['Site']['Title'];?>" width="147" height="71" border="0"></td>
    <td width="399" align="left">
      <table width="100%"  border="0" cellpadding="1" cellspacing="0">
        <tr>
          <td height="30">    <p align="center" style="font-size:12px "><b>
        <?php echo $lang['title'];?>
        </b></p></td>
        </tr>
        <tr>
          <td><?php
	$QOffice = "SELECT * FROM main_offices WHERE ref = {$_SESSION[$SESSOF]}";
	$Office = $GLOBALS['CONN']->db_array($QOffice);
	?>
        <span style="font-size:10px "> <b>
        <?php echo $Office[1]['name'];?>
        </b></td>
        </tr>
        <tr>
          <td><?php echo $Office[1]['address_street'];?></td>
        </tr>
        <tr>
          <td>Tel.
        <?php echo $Office[1]['contacts_phone'];?></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td colspan="2"><table width="550"  border="0" cellpadding="8" cellspacing="2">
        <tr>
          <td width="50%" height="0" bgcolor="#F7F7F7"><?php echo $lang['time_date'];?>
            :
              <?php echo date_output($Call[1]['operation_time']);?>
              <?php echo $lang['time_hour'];?>
            :
            <?php echo hour_output($Call[1]['operation_time']);?>
          </td>
          <td width="25%" height="0" bgcolor="#F7F7F7"><?php echo $lang['reference_store'];?>
            :
              <?php echo $Office[1]['office_number'];?></td>
          <td width="25%" height="0" bgcolor="#F7F7F7"><?php echo $lang['reference_number'];?>
            :
              <?php echo $Call[1]['control_ref'];?></td>
        </tr>
        <tr>
          <td height="0" colspan="3"><?php echo $lang['client_name'];?>
            :
              <?php
	$QClient = "SELECT * FROM main_clients WHERE ref = '{$Call[1]['main_clients_ref']}'";
	$Client = $GLOBALS['CONN']->db_array($QClient);
	print $Client[1]['name']." ".$Client[1]['name_middle']." ".$Client[1]['name_last'];?></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"><?php echo $lang['doc_type'];?>
            :
              <?php
	$QDoctypes = "SELECT * FROM main_settings_clients_doctypes WHERE ref = '{$Client[1]['id_type']}'";
	$Doctypes = $GLOBALS['CONN']->db_array($QDoctypes);
	for ($k = 1; $k <= $Doctypes[0]; $k++) {
	print $Doctypes[$k]['name'];
	} ?></td>
          <td height="0" colspan="2">
            <?php echo $lang['doc_number'];?>
            :
            <?php echo $Client[1]['id_number'];?></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"><?php echo $lang['currency_buy'];?>
            :
              <?php
	$QCurrency = "SELECT * FROM main_settings_currency WHERE ref = '{$Call[1]['in_currency_ref']}'";
	$Currency = $GLOBALS['CONN']->db_array($QCurrency);
	print $Currency[1]['icon'].$Currency[1]['name'];?></td>
          <td height="0" colspan="2"><?php echo $lang['currency_sell'];?>
            :
              <?php
	$QCurrency = "SELECT * FROM main_settings_currency WHERE ref = '{$Call[1]['out_currency_ref']}'";
	$Currency = $GLOBALS['CONN']->db_array($QCurrency);
	print $Currency[1]['icon'].$Currency[1]['name'];?>
          </td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"> <b>
            <?php echo $lang['quantity_buy'];?>
            :
            <?php echo currency_output($Call[1]['in_currency_ref'],"icon");?>
            <?php /*if ($Call[1]['type_ref'] == 1) {*/ print $Call[1]['Amount'];
//} else {print "0";}?>
          </b></td>
          <td height="0" colspan="2"><b>
            <?php echo $lang['quantity_sell'];?>
            :
            <?php //if ($Call[1]['type_ref'] == 2) { print $Call[1]['Amount'];} else {print "0";}?>
            <?php echo currency_output($Call[1]['out_currency_ref'],"icon");?>
            <?php echo $Call[1]['acerto'];?>
          </b></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"><b>
            <?php echo $lang['exchange_tax'];?>
            :
            <?php echo $Call[1]['tax1'];?>
          </b></td>
          <td height="0" colspan="2"><?php echo $lang['commission'];?>
            :
              <?php
	$QTax = "SELECT * FROM exchange_other WHERE ref = '{$Call[1]['tax2']}'";
	$Tax = $GLOBALS['CONN']->db_array($QTax);
	for ($k = 1; $k <= $Tax[0]; $k++) {
	print $Tax[$k]['value'];
	} ?></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0" bgcolor="#F7F7F7"><?php echo $lang['tax'];?>
            :
              <?php
	$QTax = "SELECT * FROM exchange_other WHERE ref = '{$Call[1]['tax3']}'";
	$Tax = $GLOBALS['CONN']->db_array($QTax);
	for ($k = 1; $k <= $Tax[0]; $k++) {
	print currency_output(1,"icon").$Tax[$k]['value'];
	} ?>
          </td>
          <td height="0" colspan="2"><b><big>
            <?php echo $lang['paied'];?>
            :
            <?php
	$QCurrency = "SELECT * FROM main_settings_currency WHERE ref = '{$Call[1]['out_currency_ref']}'";
	$Currency = $GLOBALS['CONN']->db_array($QCurrency);
	print $Currency[1]['icon'];?>
            <?php echo $Call[1]['acerto'];?>
          </big></b></td>
        </tr>
        <tr>
          <td height="0" colspan="3">Assinatura: <hr width="100%" size="1"></td>
        </tr>
        <tr>
          <td height="0" colspan="3"><div align="center">
              <?php echo $lang['tax_message'];?>
          </div></td>
        </tr>
		<tr>
          <td height="0" colspan="3"><div align="center">
              <p>
                <?php echo $lang['company_adress'];?>
                <br>
                <?php echo $lang['company_fiscal'];?>
              </p>
          </div></td>
        </tr>
    </table></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="500" height="340"  border="0" align="center">
  <tr>
    <td colspan="2" align="center"><div align="right">Duplicado</div></td>
  </tr>
  <tr>
    <td height="80" align="center"><img src="<?php echo $GLOBALS['GFX'];?>mini_logo.gif" 

alt="<?php echo $GLOBALS['Site']['Title'];?>" width="147" height="71" border="0"></td>
    <td width="399" align="left">
      <table width="100%"  border="0" cellpadding="1" cellspacing="0">
        <tr>
          <td height="30">
            <p align="center" style="font-size:12px "><b>
              <?php echo $lang['title'];?>
          </b></p></td>
        </tr>
        <tr>
          <td><?php
	$QOffice = "SELECT * FROM main_offices WHERE ref = {$_SESSION[$SESSOF]}";
	$Office = $GLOBALS['CONN']->db_array($QOffice);
	?>
              <span style="font-size:10px "> <b>
              <?php echo $Office[1]['name'];?>
            </b></span></td>
        </tr>
        <tr>
          <td><?php echo $Office[1]['address_street'];?></td>
        </tr>
        <tr>
          <td>Tel.
              <?php echo $Office[1]['contacts_phone'];?></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><table width="550"  border="0" cellpadding="8" cellspacing="2">
        <tr>
          <td width="50%" height="0" bgcolor="#F7F7F7"><?php echo $lang['time_date'];?>
            :
              <?php echo date_output($Call[1]['operation_time']);?>
              <?php echo $lang['time_hour'];?>
            :
            <?php echo hour_output($Call[1]['operation_time']);?>
          </td>
          <td width="25%" height="0" bgcolor="#F7F7F7"><?php echo $lang['reference_store'];?>
            :
              <?php echo $Office[1]['office_number'];?></td>
          <td width="25%" height="0" bgcolor="#F7F7F7"><?php echo $lang['reference_number'];?>
            :
              <?php echo $Call[1]['control_ref'];?></td>
        </tr>
        <tr>
          <td height="0" colspan="3"><?php echo $lang['client_name'];?>
            :
              <?php
	$QClient = "SELECT * FROM main_clients WHERE ref = '{$Call[1]['main_clients_ref']}'";
	$Client = $GLOBALS['CONN']->db_array($QClient);
	print $Client[1]['name']." ".$Client[1]['name_middle']." ".$Client[1]['name_last'];?></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"><?php echo $lang['doc_type'];?>
            :
              <?php
	$QDoctypes = "SELECT * FROM main_settings_clients_doctypes WHERE ref = '{$Client[1]['id_type']}'";
	$Doctypes = $GLOBALS['CONN']->db_array($QDoctypes);
	for ($k = 1; $k <= $Doctypes[0]; $k++) {
	print $Doctypes[$k]['name'];
	} ?></td>
          <td height="0" colspan="2">
            <?php echo $lang['doc_number'];?>
            :
            <?php echo $Client[1]['id_number'];?></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"><?php echo $lang['currency_buy'];?>
            :
              <?php
	$QCurrency = "SELECT * FROM main_settings_currency WHERE ref = '{$Call[1]['in_currency_ref']}'";
	$Currency = $GLOBALS['CONN']->db_array($QCurrency);
	print $Currency[1]['icon'].$Currency[1]['name'];?></td>
          <td height="0" colspan="2"><?php echo $lang['currency_sell'];?>
            :
              <?php
	$QCurrency = "SELECT * FROM main_settings_currency WHERE ref = '{$Call[1]['out_currency_ref']}'";
	$Currency = $GLOBALS['CONN']->db_array($QCurrency);
	print $Currency[1]['icon'].$Currency[1]['name'];?>
          </td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"> <b>
            <?php echo $lang['quantity_buy'];?>
            :
            <?php echo currency_output($Call[1]['in_currency_ref'],"icon");?>
            <?php /*if ($Call[1]['type_ref'] == 1) {*/ print $Call[1]['Amount'];
//} else {print "0";}?>
          </b></td>
          <td height="0" colspan="2"><b>
            <?php echo $lang['quantity_sell'];?>
            :
            <?php //if ($Call[1]['type_ref'] == 2) { print $Call[1]['Amount'];} else {print "0";}?>
            <?php echo currency_output($Call[1]['out_currency_ref'],"icon");?>
            <?php echo $Call[1]['acerto'];?>
          </b></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0"><b>
            <?php echo $lang['exchange_tax'];?>
            :
            <?php echo $Call[1]['tax1'];?>
          </b></td>
          <td height="0" colspan="2"><?php echo $lang['commission'];?>
            :
              <?php
	$QTax = "SELECT * FROM exchange_other WHERE ref = '{$Call[1]['tax2']}'";
	$Tax = $GLOBALS['CONN']->db_array($QTax);
	for ($k = 1; $k <= $Tax[0]; $k++) {
	print $Tax[$k]['value'];
	} ?></td>
        </tr>
        <tr bgcolor="#F7F7F7">
          <td height="0" bgcolor="#F7F7F7"><?php echo $lang['tax'];?>
            :
              <?php
	$QTax = "SELECT * FROM exchange_other WHERE ref = '{$Call[1]['tax3']}'";
	$Tax = $GLOBALS['CONN']->db_array($QTax);
	for ($k = 1; $k <= $Tax[0]; $k++) {
	print currency_output(1,"icon").$Tax[$k]['value'];
	} ?>
          </td>
          <td height="0" colspan="2"><b><big>
            <?php echo $lang['paied'];?>
            :
            <?php
	$QCurrency = "SELECT * FROM main_settings_currency WHERE ref = '{$Call[1]['out_currency_ref']}'";
	$Currency = $GLOBALS['CONN']->db_array($QCurrency);
	print $Currency[1]['icon'];?>
            <?php echo $Call[1]['acerto'];?>
          </big></b></td>
        </tr>
        <tr>
          <td height="0" colspan="3">Assinatura:
              <hr width="100%" size="1"></td>
        </tr>
        <tr>
          <td height="0" colspan="3"><div align="center">
              <?php echo $lang['tax_message'];?>
          </div></td>
        </tr>
        <tr>
          <td height="0" colspan="3"><div align="center">
              <p>
                <?php echo $lang['company_adress'];?>
                <br>
                <?php echo $lang['company_fiscal'];?>
              </p>
          </div></td>
        </tr>
    </table></td>
  </tr>
</table>
<div id="top" style="margin-bottom: 100%; background-color:#FFFFFF"></div>
</body>
</html>